<?php
namespace app\api\controller\wdsxh;
/**
 * 系统配置接口
 */
class System extends Base
{
    protected $noNeedLogin = ['*'];
    protected $noNeedRight = ['*'];

    public function conf(){
        $conf=$this->configObj;
        $data=array(
            'navtext'=>empty($conf['navtext'])?null:$conf['navtext'],
            'share_img'=>empty($conf['share_img'])?null:wdsxh_full_url($conf['share_img']),
            'business_foreign'=>empty($conf['business_foreign'])?0:1,
            'theme_color'=>empty($conf['theme_color'])?'#ffffff':$conf['theme_color'],
            'welcome_img'=>empty($conf['welcome_img'])?null:wdsxh_full_url($conf['welcome_img']),
            'business_img1'=>empty($conf['business_img1'])?null:wdsxh_full_url($conf['business_img1']),
            'business_img2'=>empty($conf['business_img2'])?null:wdsxh_full_url($conf['business_img2']),
            'business_img3'=>empty($conf['business_img3'])?null:wdsxh_full_url($conf['business_img3']),
            'member_unit_show'=>intval($conf['member_unit_show']),
            'member_show'=>intval($conf['member_show']),
            'member_detail_show'=>intval($conf['member_detail_show']),
            'news_show'=>intval($conf['news_show']),
            'business_show'=>intval($conf['business_show']),
            'support'=>empty($conf['support'])?null:$conf['support'],
            'news_cat'=>intval($conf['news_cat']),
            'uc_background_img'=>empty($conf['uc_background_img'])?null:wdsxh_full_url($conf['uc_background_img']),
            'news_cat_title'=>$this->newsCatName(intval($conf['news_cat'])),
            'subscribe_msg_tpl_ids'=>array(
                'initiation_admin'=>empty($conf['initiation_admin'])?null:trim($conf['initiation_admin']),
                'initiation_audit'=>empty($conf['initiation_audit'])?null:trim($conf['initiation_audit']),
                'initiation_success'=>empty($conf['initiation_success'])?null:trim($conf['initiation_success']),
                'activity_new'=>empty($conf['activity_new'])?null:trim($conf['activity_new']),
                'activity_apply'=>empty($conf['activity_apply'])?null:trim($conf['activity_apply']),
                'activity_start'=>empty($conf['activity_start'])?null:trim($conf['activity_start']),
                'member_expiretime'=>empty($conf['member_expiretime'])?null:trim($conf['member_expiretime']),
                'member_appeal'=>empty($conf['member_appeal'])?null:trim($conf['member_appeal']),
                'business_new'=>empty($conf['business_new'])?null:trim($conf['business_new']),
            ),
            'exceptions' => $conf['exceptions'],
            'index_video' => wdsxh_full_url($conf['index_video']),
        );
        $this->success($data);
    }
    private function newsCatName($cat_id){
        $data=\app\admin\model\wdsxh\ArticleCat::where('id',$cat_id)->field('name')->find();
        if($data){
            return $data['name'];
        }else{
            return null;
        }
    }
}